<template>
  <div class="app-container">
    <header :style="isShow?'background:#F4F1E9':'' ">
      <div class="web-container">
        <div class="header-left" @click="goHome">
          <img class="logo" v-if="$store.state.user.accId == '3'"  src="static/images_dz/header/logo.png" alt="">
          <img class="logo" v-else src="static/images/header/logo.png" alt="">
        </div>
        <div class="header-center">
          <el-input :style="{borderColor:$store.state.user.accId =='3'?'#e93926':'#fff'}" placeholder="请输入关键词搜索" @keyup.enter.native="goSearch" v-model="search_form.searchValue" class="input-with-select">
            <el-select v-model="search_form.searchType" slot="prepend" placeholder="图书">
              <el-option label="图书" value="1"></el-option>
              <el-option label="期刊" value="5"></el-option>
              <el-option label="报纸" value="4"></el-option>
              <el-option label="视听" value="3"></el-option>
              <el-option label="悦读" value="2"></el-option>
            </el-select>
            <el-button type="primary" slot="append" icon="el-icon-search" @click.native="goSearch">搜索</el-button>
          </el-input>
        </div>
        <div class="header-right">
          <div class="right-bookshelf">
            <el-button type="primary" round @click="goToView">
              <i class="iconfont icon-shujia"></i>
              我的书架
            </el-button>
          </div>
          <div class="right-login">
            <el-button type="primary" v-if="!isLogin" round @click="openLogin">
              <i class="iconfont icon-denglu"></i>
              登录
            </el-button>
            <el-button type="primary" v-else round @click="goToPersonalCenter">
              <i class="iconfont icon-denglu"></i>
              个人中心
            </el-button>
          </div>
        </div>
      </div>
    </header>
    <!-- <el-dialog title="更改主题颜色" :visible.sync="dialogVisible">
      <el-form class="small-space" label-position="left" label-width="130px" style='width: 400px; margin-left:50px;'>
        <el-form-item label="请选择主题颜色：" prop="resource">
          <el-radio-group v-model="themeValue">
            <el-radio label="blue">蓝色</el-radio>
            <el-radio label="green">绿色</el-radio>
            <el-radio label="red">红色</el-radio>
          </el-radio-group>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>

        <el-button type="primary" @click="handleChangeTheme">确 定</el-button>
      </div>
    </el-dialog> -->
  </div>
</template>

<script>
import { selectUserhead } from "@/api/index";
import { global } from "@/global/global";
export default {
  data() {
    return {
      search_form: {
        searchValue: "",
        searchType: "1"
      },
      dialogVisible: true,
      themeValue: ""
    };
  },
  components: {},
  computed: {
    isLogin() {
      return this.$store.state.isLogin == 1;
    },
    isShow() {
      const path = this.$route.path;
      switch (path) {
        case "/book/content":
          return true;
          break;
        case "/periodical/content":
          return true;
          break;
        case "/newspaper/content":
          return true;
          break;
        default:
          return false;
          break;
      }
    }
  },
  methods: {
    // //换肤
    // handleChangeTheme() {
    //   global.changeTheme(this.themeValue);
    //   this.dialogVisible = false;
    // },
    goSearch() {
      console.log(this.search_form);
      this.$router.push({
        name: "search",
        query: this.search_form
      });
    },
    goHome() {
      this.$store.commit("SET_ISNAVINDEX", "/");
      this.$router.push("/");
    },
    goToView() {
      this.$router.push("/bookshelf");
    },
    goToPersonalCenter() {
      selectUserhead().then(res => {
        let userInfo = res.data.date;
        this.$store.commit("SET_USERINFO", userInfo);
        this.name = userInfo.userName;
        this.cityValue = userInfo.cityCode;
        this.countyValue = userInfo.areaCode;
        this.birthDay = userInfo.birthDay;
        this.sex = userInfo.sex;
        this.describ = userInfo.describ;
      });
      this.$router.push({
        name: "personal"
      });
    },
    openLogin() {
      this.$store.commit("SET_LOGINSHOW", true);
      console.log("登录");
    }
  }
};
</script>
<style lang="less" scoped>
header {
  height: 100px;
  line-height: 100px;
  //   background-color: #15c798;
  background-color: transparent;
  width: 100%;
  .web-container {
    .header-left {
      cursor: pointer;
      float: left;
      .logo {
        height: 75px;
        vertical-align: middle;
      }
      .header-font {
        width: 115px;
        height: 29px;
        vertical-align: middle;
      }
    }
    .header-right {
      .el-button {
        // background: transparent;
      }
      margin-left: 45px;
      float: left;
      display: flex;
      .right-bookshelf {
        .icon-shujia {
          // color: #15c798;
        }
        .el-button.is-round {
          font-size: 16px;
          // color: #15c798;
          // border: 2px solid #15c798;
          border-width: 2px;
          padding: 6px 22px;
        }
      }
      .right-login {
        margin-left: 30px;
        .icon-denglu {
          // color: #15c798;
        }
        .el-button.is-round {
          font-size: 16px;
          // color: #15c798;
          // border: 2px solid #15c798;
          border-width: 2px;
          padding: 6px 22px;
        }
      }
    }
  }
}
</style>
<style lang="less">
.el-select-dropdown__item.selected {
    color: #606266;
    font-weight: 700;
  }
.custom-zxx{
  .el-input-group--append input::-webkit-input-placeholder {
    color: #15c798;
  }
}
.custom-dz{
  .header-center{
    .el-input-group__prepend {
    border: 2px solid #e93926;
    border-right:none;
  }
  input::-webkit-input-placeholder {
    color: #e93926;
  }
  .el-select .el-input .el-select__caret{
      color:#e93926;
  }
  .el-input__inner{
    border-color:#e93926;
    color:#e93926;
  }
  .el-input__inner:hover{
     border-color:#e93926;
  }
  .el-input-group__append {
    background-color: #e93926;
    user-select: none;
    top: 0px;
    border: none;
    overflow: hidden;
    color:#fff;
    border-radius: 0px 20px 20px 0;
  }
  .el-input-group__prepend div.el-select .el-input__inner {
    color: #e93926;
  }
  .el-input-group__append .el-button {
    background-color: #e93926;
    color:#fff;
  }
  }
}
.header-center {
  width: 600px;
  float: left;
  margin-left: 60px;
  input::-webkit-input-placeholder {
    color: #15c798;
  }
  .el-input__suffix{
    top:2px;
  }
  .el-select{
    user-select: none;
  }
  .el-select .el-input {
    width: 100px;
  }
  .input-with-select .el-input-group__prepend {
    background-color: transparent;
    color: #15c798;
    user-select: none;
  }
  input::-webkit-input-placeholder {
    color: #15c798;
  }
  .el-input-group__prepend {
    border: 2px solid #15c798;
    border-radius: 20px 0 0 20px;
    border-right: none;
    user-select: none;
  }
  .el-input__inner:hover{
      border-color:#15c798;
  } 
  .el-input-group__prepend div.el-select .el-input__inner {
    // color: #000;
    color: #15c798;
    width: 100%;
     height: 33px;
    line-height: 33px;
    font-size:16px;
  }
  .el-input__inner {
    background: transparent;
    border: 2px solid #15c798;
    font-size:16px;
    border-width: 2px;
    height: 33px;
    line-height: 33px;
    font-weight: normal;
    font-stretch: normal;
    letter-spacing: 0px;
    color: #15c798;
  }
  .el-input-group__append {
    user-select: none;
    top: 0px;
    border: none;
    background-color: #15c798;
    color:#fff;
    border-radius: 0px 20px 20px 0;
    overflow: hidden;
  }
  .el-select .el-input .el-select__caret{
      color:#15c798;
  }
  
  .el-input-group__append .el-button {
    width: 98px;
    // height: 40px;
    font-size: 16px;
    padding:8px 22px;
    color: #fff;
    border-radius: 0px 20px 20px 0;
  }
}
</style>


